<style type="text/css">
p.year{margin-left: 0;}
p.year a{padding: 5px 7px;}
a:hover{text-decoration: none;}
</style>
<?php echo $this->smarty_insert_scripts(array('files'=>'common.js,jquery.json.js,transport.js')); ?>
<td width="673" align="right" valign="top">
    <table width="666" border="0" cellpadding="0" cellspacing="0" class="bian">
      <tr>
        <td height="1561" align="center" valign="top">
          <table width="666" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="365" height="64" align="center" valign="top" background="themes/ecmoban_yesmywine/images/chanping0.jpg">&nbsp;</td>
            </tr>
          </table>
          <?php if ($this->_var['best_goods']): ?>
          <script type="text/javascript">
            jQuery.noConflict()
            function show_goods(id) {
              //jQuery('.theme-popover-mask').fadeIn(2000);
              jQuery('.theme-popover-mask').show();
              jQuery('.theme-popover-mask').height(jQuery(document).height());
              jQuery('#goods_detail'+id).fadeIn(2000);
              document.forms['ECS_FORMBUY'+id].reset();
              //jQuery("#year"+id).find("a").removeClass("on");
              //jQuery("#year"+id+">a:first-child").addClass("on");
              changePrice(id);
            }
            function close_goods(id){
              //jQuery('.theme-popover-mask').fadeOut(2000);
              //jQuery('#goods_detail'+id).fadeOut(2000);
              jQuery('#goods_detail'+id).hide();
              jQuery('.theme-popover-mask').hide();
            }
          </script>
          <table width="647" border="0" cellspacing="0" cellpadding="5">
            <?php $_from = $this->_var['best_goods']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('', 'goods');$this->_foreach['goods'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['goods']['total'] > 0):
    foreach ($_from AS $this->_var['goods']):
        $this->_foreach['goods']['iteration']++;
?>
            <?php if (($this->_foreach['goods']['iteration'] - 1) % 2 == 0): ?><tr><?php endif; ?>
              <td <?php if (($this->_foreach['goods']['iteration'] - 1) % 2 == 0): ?>width="300"<?php else: ?>width="327"<?php endif; ?> align="center" valign="middle">
                <table width="270" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="30" align="left" valign="middle" class="ziti1"><?php echo $this->_var['goods']['short_style_name']; ?></td>
                  </tr>
                  <tr>
                    <td height="195" align="center" valign="middle">
                      <table width="270" border="0" cellpadding="0" cellspacing="0" class="bian">
                        <tr>
                          <td width="74" height="195" align="center" valign="middle"><img src="<?php echo $this->_var['goods']['thumb']; ?>" class="bigtimg" width="68" height="195" onclick="show_goods(<?php echo $this->_var['goods']['id']; ?>)" /></td>
                          <td width="196" align="center">
                            <table width="183" height="98" border="0" cellpadding="0" cellspacing="0" class="ziti2">
                              <tr>
                                <td height="98"><?php echo $this->_var['goods']['brief']; ?></td>
                              </tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                  <tr>
                    <td height="24" align="right" valign="middle"><a href="<?php echo $this->_var['goods']['url']; ?>">详文及购买 </a></td>
                  </tr>
                </table>
                
                <table class="theme-popover" id="goods_detail<?php echo $this->_var['goods']['id']; ?>" width="1017" height="504" border="0" align="center" cellpadding="0" cellspacing="0" background="themes/ecmoban_yesmywine/images/di2.png" style="display:none;">
                  <tr>
                    <td width="988" height="454" align="center" valign="middle">
                    <table width="970" height="460" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                      <td width="440" rowspan="2" align="center" valign="middle"><img src="<?php echo $this->_var['goods']['goods_img']; ?>" width="440" height="440" /></td>
                      <td width="485" height="27" align="right" onclick="close_goods(<?php echo $this->_var['goods']['id']; ?>)"><img src="themes/ecmoban_yesmywine/images/x.jpg" width="21" height="21" /></td>
                      <td width="45" align="center" class="guanbi STYLE1" onclick="close_goods(<?php echo $this->_var['goods']['id']; ?>)">关闭</td>
                      </tr>
                      <tr>
                      <td height="427" colspan="2" align="center" valign="middle">
                        <table width="513" height="44" border="0" cellpadding="0" cellspacing="0" class="bian2s">
                        <tr>
                          <td width="501" height="44" colspan="3" align="left" class="zi13"><?php echo $this->_var['goods']['name']; ?><span style="float:right;font-size:14px;"><a href="<?php echo $this->_var['goods']['url']; ?>">详文及购买</a></span></td>
                        </tr>
                        </table>
                        <table width="513" height="382" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                          <td height="251" colspan="3" align="left"><span class="zitis"><?php echo $this->_var['goods']['brief']; ?></span></td>
                          </tr>
                          <tr>
                          <td width="501" height="131" colspan="3" align="left" valign="bottom">
                            <form action="javascript:addToCart_index(<?php echo $this->_var['goods']['id']; ?>)" method="post" name="ECS_FORMBUY<?php echo $this->_var['goods']['id']; ?>" id="ECS_FORMBUY<?php echo $this->_var['goods']['id']; ?>" >
                              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                  <td>
                                    
                                    <?php $_from = $this->_var['goods']['specification']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('spec_key', 'spec');if (count($_from)):
    foreach ($_from AS $this->_var['spec_key'] => $this->_var['spec']):
?>
                                    <?php if ($this->_var['spec']['name'] == '年份'): ?>
                                    <div>
                                      <?php if ($this->_var['spec']['attr_type'] == 1): ?>
                                      <p class="year">
                                        <select name="spec_<?php echo $this->_var['spec_key']; ?>" onchange="changePrice(<?php echo $this->_var['goods']['id']; ?>)" style="width:70px;">
                                          <?php $_from = $this->_var['spec']['values']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'value');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['value']):
?>
                                          <option label="<?php echo $this->_var['value']['label']; ?>" value="<?php echo $this->_var['value']['id']; ?>"><?php echo $this->_var['value']['label']; ?></option>
                                          <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                        </select>
                                      </p>
                                      <input type="hidden" name="spec_list" value="<?php echo $this->_var['key']; ?>" />
                                      <?php else: ?>
                                      <p class="year">
                                        <?php $_from = $this->_var['spec']['values']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'value');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['value']):
?>
                                        <a onclick="changeAtt(this,<?php echo $this->_var['goods']['id']; ?>)"  href="javascript:;" name="<?php echo $this->_var['value']['id']; ?>"><ins></ins><?php echo $this->_var['value']['label']; ?>
                                        <input type="checkbox" style="display:none"  name="spec_<?php echo $this->_var['spec_key']; ?>"  value="<?php echo $this->_var['value']['id']; ?>"  id="spec_value_<?php echo $this->_var['value']['id']; ?>" /></a>
                                        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                      </p>
                                      <input type="hidden" name="spec_list" value="<?php echo $this->_var['key']; ?>" />
                                      <?php endif; ?>
                                    </div>
                                    <?php endif; ?>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                    
                                  </td>
                                  <td>
                                    
                                    <?php $_from = $this->_var['goods']['specification']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('spec_key', 'spec');if (count($_from)):
    foreach ($_from AS $this->_var['spec_key'] => $this->_var['spec']):
?>
                                    <?php if ($this->_var['spec']['name'] != '年份'): ?>
                                    <div>
                                      <?php if ($this->_var['spec']['attr_type'] == 1): ?>
                                      <p class="year" id="year<?php echo $this->_var['goods']['id']; ?>">
                                        <?php $_from = $this->_var['spec']['values']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'value');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['value']):
?>
                                        <a <?php if ($this->_var['key'] == 0): ?>class="on"<?php endif; ?> onclick="changeAtt(this,<?php echo $this->_var['goods']['id']; ?>)" href="javascript:;" name="<?php echo $this->_var['value']['id']; ?>"><ins></ins><?php echo $this->_var['value']['label']; ?>
                                        <input style="display:none" id="spec_value_<?php echo $this->_var['value']['id']; ?>" type="radio" name="spec_<?php echo $this->_var['spec_key']; ?>" value="<?php echo $this->_var['value']['id']; ?>" <?php if ($this->_var['key'] == 0): ?>checked<?php endif; ?> /></a>
                                        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                      </p>
                                      <input type="hidden" name="spec_list" value="<?php echo $this->_var['key']; ?>" />
                                      <?php else: ?>
                                      <p class="year" id="year<?php echo $this->_var['goods']['id']; ?>">
                                        <?php $_from = $this->_var['spec']['values']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }; $this->push_vars('key', 'value');if (count($_from)):
    foreach ($_from AS $this->_var['key'] => $this->_var['value']):
?>
                                        <a onclick="changeAtt(this,<?php echo $this->_var['goods']['id']; ?>)"  href="javascript:;" name="<?php echo $this->_var['value']['id']; ?>"><ins></ins><?php echo $this->_var['value']['label']; ?>
                                        <input type="checkbox" style="display:none"  name="spec_<?php echo $this->_var['spec_key']; ?>"  value="<?php echo $this->_var['value']['id']; ?>"  id="spec_value_<?php echo $this->_var['value']['id']; ?>" /></a>
                                        <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                      </p>
                                      <input type="hidden" name="spec_list" value="<?php echo $this->_var['key']; ?>" />
                                      <?php endif; ?>
                                    </div>
                                    <?php endif; ?>
                                    <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
                                    
                                  </td>
                                  <td style="color:#B63547;font-size:20px;"><span id="SHOP_PRICE<?php echo $this->_var['goods']['id']; ?>"><?php echo $this->_var['goods']['shop_price']; ?></span></td>
                                  <td>购买数量：<input type="text" name="goods_number" value="1" id="goods_number<?php echo $this->_var['goods']['id']; ?>" size="4" onblur="changePrice(<?php echo $this->_var['goods']['id']; ?>)"></td>
                                  <td><a href="javascript:addToCart_index(<?php echo $this->_var['goods']['id']; ?>);" style="background:url(themes/ecmoban_yesmywine/images/tuiche.jpg) no-repeat;width:71px;height:65px;display:block;">&nbsp;</a></td>
                                </tr>
                                <!-- <tr><td colspan="2">&nbsp;</td></tr>
                                <tr>
                                  <td colspan="2"><a href="javascript:addToCart_index(<?php echo $this->_var['goods']['id']; ?>);" style="background:url(themes/puke/images/cart.jpg) no-repeat;width:162px;height:44px;display:block;">&nbsp;</a></td>
                                </tr> -->
                              </table>
                            </form>
                          </td>
                          </tr>
                        </table>
                      </td>
                      </tr>
                    </table>
                  </td>
                  </tr>
                </table>    
                
              </td>
            <?php if ($this->_foreach['goods']['iteration'] % 2 == 0 || ($this->_foreach['goods']['iteration'] == $this->_foreach['goods']['total'])): ?></tr><?php endif; ?>
            <?php endforeach; endif; unset($_from); ?><?php $this->pop_vars();; ?>
          </table>          
          <?php else: ?>
          <table width="647" border="0" cellspacing="0" cellpadding="5">
            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
          </table>
          <?php endif; ?>
        </td>
      </tr>
    </table>
</td>

<script type="text/javascript">

/**
 * 点选可选属性或改变数量时修改商品价格的函数
 */
function changePrice(id)
{
  var attr = getSelectedAttributes(document.forms['ECS_FORMBUY'+id]);
 
  var qty = document.forms['ECS_FORMBUY'+id].elements['goods_number'].value;

  Ajax.call('index.php', 'act=price&id=' + id + '&attr=' + attr + '&number=' + qty, changePriceResponse, 'GET', 'JSON');
}


/**
 * 接收返回的信息
 */
function changePriceResponse(res)
{
  if (res.err_msg.length > 0)
  {
    alert(res.err_msg);
  }
  else
  {
    id = res.goods_id;
    document.forms['ECS_FORMBUY'+id].elements['goods_number'].value = res.qty;

    if (document.getElementById('ECS_GOODS_AMOUNT'))
      document.getElementById('ECS_GOODS_AMOUNT').innerHTML = res.result;
    
     if (document.getElementById('SHOP_PRICE'+id))
      document.getElementById('SHOP_PRICE'+id).innerHTML = res.result;
  }
}

function changeAtt(t,id) {
  t.lastChild.checked='checked';
  for (var i = 0; i<t.parentNode.childNodes.length;i++) {
      if (t.parentNode.childNodes[i].className == 'on') {
        t.parentNode.childNodes[i].className = '';
      }
    }
  t.className = "on";
  changePrice(id);
}

</script>